﻿
Partial Class store_UCSet
    Inherits System.Web.UI.UserControl

    Public Sub Display(p As CProduct)
        lnkName.Text = p.ProductName 'AndPrice
        lnkName.NavigateUrl = CSitemap.Decide(p)

        If Not p.IsEnglish Then
            lnkNameChineseSimplified.Text = p.ProductNameChineseSimplified
            lnkNameChineseSimplified.ToolTip = p.ProductNameChineseSimplified
            lnkNameChineseSimplified.NavigateUrl = CSitemap.Decide(p)
        Else
            lnkNameChineseSimplified.Visible = False
        End If

        If p.HasImage Then
            lnkThumb.NavigateUrl = CSitemap.Decide(p)
            lnkThumb.Visible = True
            lnkThumb.ImageUrl = CSitemap.ProductThumb(p)
        ElseIf p.ProductSpeakerId = ESpeaker.MikeConnell Then
            lnkThumb.NavigateUrl = CSitemap.Decide(p)
            lnkThumb.Visible = True
            lnkThumb.ImageUrl = "~/images/default.jpg"
        Else
            divBorder.Visible = False
        End If

        lnkOrderNow.NavigateUrl = CSitemap.Decide(p)

        litDescription.Text = p.Description_Br
        If Not p.IsEnglish Then
            litDescriptionChineseSimplified.Text = p.DescriptionChineseSimp_Br
        Else
            litDescriptionChineseSimplified.Visible = False
        End If

        If p.ProductCSBookIdOrParent > 0 Then
            lnkPaperback.Visible = True
            lnkPaperback.NavigateUrl = CSitemap.External_CreateSpace(p.ProductCSBookIdOrParent)
        End If
        If Not String.IsNullOrEmpty(p.ProductVimeoChannelIdOrParent) Then
            lnkVimeo.Visible = True
            lnkVimeo.NavigateUrl = p.VideoUrl_VimeoChannel
        End If
        If Not String.IsNullOrEmpty(p.ProductYouTubePlaylistIdOrParent) Then
            lnkYouTube.Visible = True
            lnkYouTube.NavigateUrl = p.VideoUrl_YouTubePlaylist
        End If
        If Not String.IsNullOrEmpty(p.ProductAmazonIdOrParent) Then
            lnkKindle.Visible = True
            lnkKindle.NavigateUrl = CSitemap.External_Amazon(p.ProductAmazonIdOrParent)
        End If


        lnkOrderNow.ToolTip = p.ProductName
        lnkName.ToolTip = p.ProductName
        lnkThumb.ToolTip = p.ProductName

        lblLanguage.Text = p.LanguageName
        lblLanguage.Visible = p.ProductLanguageId <> ELanguage.English

        For Each i As CProduct In p.Children.Active.Ordered
            UCContent(plh).Display(i)
        Next

        plh.Style.Add("max-width", "350px")
        plh.Style.Add("overflow", "auto")
        If plh.Controls.Count > 7 + 5 Then
            plh.Style.Add("height", "210px")
            'plh.Style.Add("overflow", "auto")
            divDesc.Style("height") = "250px"
        ElseIf litDescription.Text.Length < 100 Then
            divDesc.Style("height") = "auto"
        End If

    End Sub


#Region "User Controls"
    Private Shared Function UCContent(ByVal target As Control) As UCContent
        Dim ctrl As Control = target.Page.LoadControl(CSitemap.Store_UCContent)
        target.Controls.Add(ctrl)
        Return CType(ctrl, UCContent)
    End Function
#End Region

End Class
